package mid;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class offer35_最小时间差 {
    public int findMinDifference(List<String> timePoints) {
        if (timePoints.size()>1440){
            return 0;
        }
        List<Integer> list=new ArrayList<>();
        for (String s : timePoints) {
            String[] time=s.split(":");
            list.add(Integer.parseInt(time[0])*60+Integer.parseInt(time[1]));
        }
        Collections.sort(list);
        list.add(list.get(0)+1440);
        int res=Integer.MAX_VALUE;
        for (int i = 1; i < list.size(); i++) {
            res=Math.min(res,list.get(i)-list.get(i-1));
        }
        return res;
    }
}
